﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Meraz.Core.Model;
using System.IO;

namespace Meraz.Core.Helpers
{
    public static class Util
    {
        public static Stream ToStream(string text)
        {
            byte[] byteArray = Encoding.UTF8.GetBytes(text);
            return new MemoryStream(byteArray); 
        }
        public static String ToString(Stream stream)
        {
            StreamReader reader = new StreamReader(stream);
            string text = reader.ReadToEnd();
            return text;
        }
        public static Func<T, string> GetField<T>(string field)
        {
            PropertyInfo propertyInfo = typeof(T).GetProperty(field);
            return obj => Convert.ToString(propertyInfo.GetValue(obj, null));
        }
        
    }
}
